package com.it.myh;

/**
 * @Description: // 类说明，在创建类时要填写
 * @ClassName: Ev_0220_04    // 类名，会自动填充
 * @Author: MYH          // 创建者
 * @Date: 2023/2/20 11:57   // 时间
 * @Version: 1.0     // 版本
 */
class Per{

    private String name;

    private Integer age;

    public Per() {
    }

    public Per(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Per{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

class MYH extends Per{

    private char sex;

    public MYH() {
    }

    public MYH(char sex) {
        this.sex = sex;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "MYH{" +
                "sex=" + sex +
                '}';
    }
}

public class Ev_0220_04 {

    public static void main(String[] args) {
        //强制类型转换的前提是多态！
        Per per = new MYH('男');
        MYH myh = (MYH) per;
        System.out.println(myh.getSex());
    }
}
